package MFL.handler;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import org.apache.commons.dbutils.ResultSetHandler;

import bean.comment;
import bean.orders;
import bean.orderltem;
import bean.product;
import bean.receiverMsg;

public class orderdetailResultSetHandler  implements ResultSetHandler<List<orderltem>>{

	@Override
	public List<orderltem> handle(ResultSet rs) throws SQLException {
		// TODO Auto-generated method stub
		List<orderltem> orderltem1=new ArrayList<>();
		while (rs.next()) {
			orderltem  info=new orderltem();
			info.setId(rs.getInt("id"));
			info.setOrderid(rs.getInt("orderId"));
			info.setUserid(rs.getInt("userId"));
			info.setProid(rs.getInt("proId"));
			info.setQuantity(rs.getInt("quantity"));
			info.setTotalprice(rs.getInt("totalPrice"));
			info.setState(rs.getInt("state"));
			info.setCreatetime(rs.getDate("createTime"));
			
			product info2=new product();
			info2.setProid(rs.getInt("proId"));
			info2.setProname(rs.getString("proName"));
			info2.setPrice2(rs.getDouble("price2"));
			info.setPinfo(info2);
			
			receiverMsg info3=new receiverMsg();
			info3.setId(rs.getInt("userId"));
			info3.setReceivername(rs.getString("receiverName"));
			info3.setReceiverphone(rs.getString("receiverPhone"));
			info.setRinfo(info3);
			
			orders info4=new orders();
			info4.setUpdatetime(rs.getDate("updateTime"));
			info4.setEndtime(rs.getDate("endTime"));
			info.setOinfo(info4);
			
			orderltem1.add(info);
		}
		
		return orderltem1;
	}

}
